package org.arch_learn.dubbo_demo.dubbo_spi_router_demo;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class ZookeeperClients {
    private final CuratorFramework client;
    private static ZookeeperClients INSTANCE;

    static {
        ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework newClient = CuratorFrameworkFactory.newClient("127.0.0.1:2181", retryPolicy);
        INSTANCE = new ZookeeperClients(newClient);
        newClient.start();
    }

    private ZookeeperClients(CuratorFramework client) {
        this.client = client;
    }

    public static CuratorFramework client() {
        return INSTANCE.client;
    }
}
